package com.dg.gdx.screens;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.assets.AssetManager;
import com.dg.gdx.screens.listeners.LoadingListener;

public class LoadingScreen extends SplashScreen {

	private boolean isLoad;

	private LoadingListener loadingListener;
	private AssetManager manager;

	public LoadingScreen(Game game, AssetManager manager) {
		super(game, 0);
		this.setManager(manager);
	}

	@Override
	public void render(float delta) {
		super.render(delta);
		if (manager.update() && !isLoad() && isTimeOver()) {
			isLoad = true;
			if (loadingListener != null) {
				loadingListener.onLoad();
			}
		}
	}

	public LoadingListener getLoadingListener() {
		return loadingListener;
	}

	public void setLoadingListener(LoadingListener loadingListener) {
		this.loadingListener = loadingListener;
	}

	public AssetManager getManager() {
		return manager;
	}

	public void setManager(AssetManager manager) {
		this.manager = manager;
	}

	public boolean isLoad() {
		return isLoad;
	}

	public void setLoad(boolean isLoad) {
		this.isLoad = isLoad;
	}

}
